package com.ruicar.afs.cloud.admin.gwmgc.sso.controller;

import com.ruicar.afs.cloud.admin.gwmgc.sso.dto.SsoRequestDto;
import com.ruicar.afs.cloud.admin.gwmgc.sso.dto.SsoResponseDto;
import com.ruicar.afs.cloud.admin.gwmgc.sso.dto.SsoUserDto;
import com.ruicar.afs.cloud.admin.gwmgc.sso.service.SsoService;
import com.ruicar.afs.cloud.common.core.util.IResponse;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sso")
@AllArgsConstructor
public class GwmfcController {
    private final SsoService ssoService;
    @PostMapping("/tokenValidate")
    public IResponse<SsoResponseDto> tokenValidate(@RequestBody SsoRequestDto ssoRequestDto){
        return IResponse.success(ssoService.validate(ssoRequestDto));
    }

    @PostMapping("/useradd")
    public String userAdd(@RequestBody SsoUserDto ssoUserDto, @RequestHeader("token") String token){
        return ssoService.addUser(ssoUserDto,token);
    }

    @PostMapping("/userdel")
    public String userDisable(@RequestBody SsoUserDto ssoUserDto, @RequestHeader("token") String token){
        return ssoService.userDisable(ssoUserDto,token);
    }

    @PostMapping("/refreshSSoToken")
    public IResponse<SsoResponseDto> refreshSSoToken(@RequestBody SsoRequestDto ssoUserDto){
        return IResponse.success(ssoService.refreshToken(ssoUserDto));
    }
}
